#include "list.h"

HEAD_NODE *CommandListA=NULL;
u32 count=0;

int main()
{
	EVENT event[10] = {0};

	CommandListA = (HEAD_NODE *)malloc(sizeof(HEAD_NODE));
	if(CommandListA==NULL)
		printf("list malloc failed\n");
	memset((u8*)CommandListA, 0, sizeof(HEAD_NODE));

	event[0].Time = 1000*2 ;
	event[0].lenth = sizeof("hello_event_0");
	memcpy(event[0].data, "hello_event_0", event[0].lenth);

	event[1].Time = 1000*3 ;
	event[1].lenth = sizeof("hello_event_1");
	memcpy(event[1].data, "hello_event_1", event[1].lenth);

	event[2].Time = 1000*5 ;
	event[2].lenth = sizeof("hello_event_2");
	memcpy(event[2].data, "hello_event_2", event[2].lenth);

	event[3].Time = 1000*6 ;
	event[3].lenth = sizeof("hello_event_3");
	memcpy(event[3].data, "hello_event_3", event[3].lenth);

	event[4].Time = 1000*6.2 ;
	event[4].lenth = sizeof("hello_event_4")+2;
	event[4].data[0] = 0x12;
	event[4].data[1] = 0x34;
	memcpy(event[4].data + 2, "hello_event_4", event[4].lenth);

	event[5].Time = 1000*1 ;
	event[5].lenth = sizeof("hello_event_5");
	memcpy(event[5].data, "hello_event_5", event[5].lenth);

	insert_event(&event[3]);
	insert_event(&event[4]);
	insert_event(&event[0]);
	insert_event(&event[2]);
	insert_event(&event[1]);
	insert_event(&event[5]);

	printf("now CommandListA-num %d\n", CommandListA->NUM);

	Cmd_Event_Add(0x1235, print_0x1235);
	Cmd_Event_Add(0x1234, print_0x1234);
	Cmd_Event_Add(0x1236, print_0x1236);

	while(1)
	{
		if(do_time_event(&event[10]) == 0)
		{
			printf("Time  = %lld\n", event[10].Time);
			printf("lenth = %d\n",   event[10].lenth);
			printf("CommandListA-num %d\n", CommandListA->NUM);
		}
		usleep(1000);
		count++;
	}

    return 0;
}

